package com.tutucms.service.configuration;

import com.tutucms.service.auth.UserContextCache;
import com.tutucms.service.auth.impl.DefaultUserContextCache;
import com.tutucms.service.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by wangxudong on 2020/10/28.
 *
 * @version: 1.0
 * @modified :
 */
@Configuration
public class UserContextCacheConfig {

    @Bean
    @ConditionalOnBean(CacheService.class)
    @ConditionalOnMissingBean
    public UserContextCache defaultUserContextCache(CacheService cacheService) {

        DefaultUserContextCache cache = new DefaultUserContextCache();
        cache.setCacheService(cacheService);

        return cache;
    }
}
